//
// Description: 6027. 统计数组中峰和谷的数量
// Created by Loading on 2022/3/20.
//

#include <bits/stdc++.h>

using namespace std;

int countHillValley(vector<int> &nums) {
    // 去重，并取长度
    int n = unique(nums.begin(), nums.end()) - nums.begin();

    int res = 0;
    for (int i = 1; i < n - 1; ++i) {
        if ((nums[i - 1] - nums[i]) * (nums[i + 1] - nums[i]) > 0) {
            ++res;
        }
    }

    return res;
}

int main() {
    vector<int> nums{2, 4, 1, 1, 6, 5};
    int res = countHillValley(nums);
    cout << res << endl;

    return 0;
}